<template>
  <el-dialog v-dialogDrag :visible.sync="dialogVisible" title="MRP计算详情" width="1000px">
    <el-row>
      <el-table border class="tabOver" stripe height="450px" :data="materials">
        <el-table-column label="物料" align="center" :width="[1,2].includes(ruleForm.status) ? '150px' : ''">
          <template #default="{ row }">{{row.materialName}}{{row.materialCode !== '' ? '-【' + row.materialCode + '】' : ''}}</template>
        </el-table-column>
        <el-table-column prop="unit" label="单位" width="80px" align="center" />
        <el-table-column prop="needNum" label="需求数量" width="100px" align="center" />
        <el-table-column prop="orderNum" label="在订数量" width="100px" align="center" />
        <el-table-column prop="pickNum" label="已领数量" width="90px" align="center" />
        <el-table-column prop="planReqNum" label="计划请购" width="90px" align="center" />
        <el-table-column prop="reqNum" label="请购数量" width="90px" align="center" />
        <el-table-column prop="stockNum" label="缺货数量" width="90px" align="center" />
        <el-table-column prop="wmsNum" label="库存数量" width="90px" align="center" />
      </el-table>
    </el-row>
    <el-row class="bottomCont">
      <el-col :span="8">制单人：{{ rows.enterName ? rows.enterName : this.$store.getters.compInfo.userName }}</el-col>
      <el-col :span="8" style="text-align: center">审核：{{rows.enterName ? rows.enterName : $store.getters.compInfo.userName}}</el-col>
      <el-col :span="8" style="text-align: right">制单时间：{{ rows.enterAt }}</el-col>
    </el-row>
  </el-dialog>
</template>
<script>
export default {
  props: {},
  data() {
    return {
      title: '',
      ruleForm: {},
      materials: [],
      dialogVisible: false,
      rows: {}
    }
  },
  watch: {},
  mounted() {},
  methods: {
    async showDialog(row, obj) {
      this.rows = row
      await this.getDetail(obj)
      this.dialogVisible = true
    },
    /* 编辑获取详情 */
    async getDetail(obj) {
      const loading = this.$loading({
        lock: true,
        text: '数据加载中...', // 数据加载中...
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      const res = await this.$axios.post(`/pro/plan/getMrp`, obj)
      if (res.data.code === 200) {
        loading.close()
        this.materials = res.data.data
      }
    }
  }
}
</script>
<style lang='scss' scoped>
</style>
